package com.spring.sunflower.common

import com.spring.sunflower.base.BaseObserver
import com.spring.sunflower.base.BasePresenter
import com.spring.sunflower.bean.TaskAwardDailyBean
import com.spring.sunflower.bean.TaskAwardSignBean

/**
 * Created by Kevin on 2021/8/27<br/>
 *
 * Describe:<br/>
 */
class AwardPresenter(baseView: CommonContract.AwardView) :
    BasePresenter<CommonContract.AwardView>(baseView) {
    fun getDailyAward(pageIndex: String) {
        val observable = requestDataSource.awardDaily("daily", pageIndex)
        addDisposable(observable, object : BaseObserver<TaskAwardDailyBean>(baseView) {
            override fun onSuccess(bean: TaskAwardDailyBean) {
                baseView.showDailyAward(bean.datas!!)
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }

    fun getNewerAward(pageIndex: String) {
        val observable = requestDataSource.awardDaily("newbie", pageIndex)
        addDisposable(observable, object : BaseObserver<TaskAwardDailyBean>(baseView) {
            override fun onSuccess(bean: TaskAwardDailyBean) {
                baseView.showNewerAward(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }

    fun getSignAward(pageIndex: String) {
        val observable = requestDataSource.awardSign(pageIndex)
        addDisposable(observable, object : BaseObserver<TaskAwardSignBean>(baseView) {
            override fun onSuccess(bean: TaskAwardSignBean) {
                baseView.showSignAward(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }
}